﻿//04.Write methods that calculate the surface of a triangle by given:
//Side and an altitude to it; Three sides; Two sides and an angle between them. Use System.Math.

using System;

namespace TriangleSurface
{
    class TriangleSurface
    {
        static double BySideAndAltitude(double a, double altitude)
        {
            double S = (a * altitude) / 2;
            return S;
        }

        static double ByTwoSidesAnAngle(double a, double b, double angle)
        {
            double AngleInRadians = Math.PI * angle / 180.0;
            double sinGama = Math.Sin(AngleInRadians);
            double S = (a * b * sinGama) / 2;
            return S;
        }
        static double ByThreeSides(double a, double b, double c)
        {
            double p = (a + b + c) / 2;
            double S = Math.Sqrt(p * (p - a) * (p - b) * (p - c));
            return S;
        }
        static void Main()
        {
            Console.Write("Select a metods: 1, 2 or 3");
            int method = int.Parse(Console.ReadLine());

            double a, b, c, angle, altitude;

            if (method == 1)
            {
                Console.Write("a = ");
                a = double.Parse(Console.ReadLine());
                Console.Write("b = ");
                b = double.Parse(Console.ReadLine());
                Console.Write("c = ");
                c = double.Parse(Console.ReadLine());
                Console.WriteLine("The surface is = {0}", ByThreeSides(a, b, c));
            }
            else if (method == 2)
            {
                Console.Write("a = ");
                a = double.Parse(Console.ReadLine());
                Console.Write("b = ");
                b = double.Parse(Console.ReadLine());
                Console.Write("angle = ");
                angle = double.Parse(Console.ReadLine());
                Console.WriteLine("The surface is = {0}", ByTwoSidesAnAngle(a, b, angle));
            }
            else if (method == 3)
            {
                Console.Write("a = ");
                a = double.Parse(Console.ReadLine());
                Console.Write("altitude = ");
                altitude = double.Parse(Console.ReadLine());
                Console.WriteLine("The surface is = {0}", BySideAndAltitude(a, altitude));
            }
        }
    }
}
